<?php

declare(strict_types=1);

namespace app\model;

use think\model\concern\SoftDelete;
use app\model\common\BaseModel;
use app\model\common\HasPswdTrait;
use app\model\common\LoginCacheTrait;

/**
 * 示例模型
 */
class ExampleFull extends BaseModel
{
    public static $modelAlias = '完整示例模型';

    protected $table = 'example';
    protected $pk = 'id';

    use SoftDelete;
    protected $deleteTime = 'delete_time';
    protected $defaultSoftDelete = 0;

    /** ---- 常量 ---- */
    /**
     * @var array 状态类型枚举
     */
    public const state_map = [
        ['id' => 1, 'name' => '上架'],
        ['id' => 2, 'name' => '下架'],
    ];

    /** ---- 获取/修改器 ---- */
    public function getStateAttr()
    {
        $key = array_search($this['state_id'], array_column(static::state_map, 'id'));
        if ($key === false) return null;
        return static::state_map[$key];
    }

    /** ---- 查询范围 ---- */

    /** ---- 关联 ---- */

    /** ---- 自定义方法 ---- */
}
